@import "~terriajs-variables";

@mixin transition($transition...) {
  -moz-transition: $transition;
  -o-transition: $transition;
  -webkit-transition: $transition;
  transition: $transition;
}

@mixin transform($transforms) {
  -moz-transform: $transforms;
  -o-transform: $transforms;
  -ms-transform: $transforms;
  -webkit-transform: $transforms;
  transform: $transforms;
}
// rotate
@mixin rotate($deg) {
  @include transform(rotate(#{$deg}deg));
}

// scale
@mixin scale($scale) {
  @include transform(scale($scale));
}
// translate
@mixin translate($x, $y) {
  @include transform(translate($x, $y));
}
// skew
@mixin skew($x, $y) {
  @include transform(skew(#{$x}deg, #{$y}deg));
}
//transform origin
@mixin transform-origin($origin) {
  moz-transform-origin: $origin;
  -o-transform-origin: $origin;
  -ms-transform-origin: $origin;
  -webkit-transform-origin: $origin;
  transform-origin: $origin;
}
//transform origin
@mixin transform-origin($origin, $origin2) {
  moz-transform-origin: $origin $origin2;
  -o-transform-origin: $origin $origin2;
  -ms-transform-origin: $origin $origin2;
  -webkit-transform-origin: $origin $origin2;
  transform-origin: $origin $origin2;
}

// animation mixins
@mixin keyframes($animation-name) {
  @-webkit-keyframes #{$animation-name} {
    @content;
  }
  @-moz-keyframes #{$animation-name} {
    @content;
  }
  @-ms-keyframes #{$animation-name} {
    @content;
  }
  @-o-keyframes #{$animation-name} {
    @content;
  }
  @keyframes #{$animation-name} {
    @content;
  }
}
@mixin animation($animation-name) {
  -webkit-animation: #{$animation-name};
  -moz-animation: #{$animation-name};
  -ms-animation: #{$animation-name};
  -o-animation: #{$animation-name};
  animation: #{$animation-name};
}

@mixin icon-font($content) {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: "icomoon" !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  content: $content;
}

/* Mixin */
@mixin vertical-align($position: relative) {
  position: $position;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}

//Wrapping text only, not url
%wrap {
  /* These are technically the same, but use both */
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}
// Use this to override wrap
%unwrap {
  overflow-wrap: normal;
  word-wrap: normal;
  word-break: normal;
}
// currently not used, but just in case we need it
%url {
  word-break: break-all;
  hyphens: none;
}

%truncate {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@mixin empty-module($module-name) {
  .#{$module-name} {
    /*!*/
  }
}

// %link is deprecated. Instead of @extend %link;, use @include link($bg-color);
%link {
  @if variable-exists(text-link) {
    color: $text-link;
  } @else {
    color: $color-primary; // for backwards compatibility
  }
  text-decoration: $link-text-decoration;
  &:visited {
    @if variable-exists(text-visited-link) {
      color: $text-visited-link;
    } @else {
      color: $color-primary;
    }
  }
}

@mixin link($bg-color) {
  text-decoration: $link-text-decoration;
  color: get-link-color($bg-color);
  &:visited {
    color: get-visited-link-color($bg-color);
  }
}

@mixin placeholder {
  &::placeholder {
    @content;
  }

  &::-webkit-input-placeholder {
    // Chrome/Opera/Safari
    @content;
  }

  &:-moz-placeholder {
    // Firefox 18-
    @content;
  }

  &::-moz-placeholder {
    // Firefox 19+
    @content;
  }

  &:-ms-input-placeholder {
    // IE 10+
    @content;
  }
}

%sm-show,
%md-show,
%lg-show {
  display: none !important;
}

@media (min-width: $sm) {
  %sm-show {
    display: block !important;
  }
}

@media (min-width: $md) {
  %md-show {
    display: block !important;
  }
}

@media (min-width: $lg) {
  %lg-show {
    display: block !important;
  }
}

@media (min-width: $sm) {
  %sm-hide {
    display: none !important;
  }
}

@media (min-width: $md) {
  %md-hide {
    display: none !important;
  }
}

@media (min-width: $lg) {
  %lg-hide {
    display: none !important;
  }
}

%clearfix {
  clear: both;

  &:before,
  &:after {
    content: " ";
    display: table;
    clear: both;
  }
}
